package com.vcar.LDiceClient.command
{
    import com.vcar.LDiceClient.config.Config;
    import com.vcar.LDiceClient.config.ModuleName;
    import com.vcar.LDiceClient.config.ProxyNames;
    import com.vcar.LDiceClient.core.ModWindowManager;
    import com.vcar.LDiceClient.dataproxy.SocketProxy;
    import com.vcar.LDiceClient.manager.TickManager;
    
    import flash.events.Event;
    
    import org.puremvc.as3.interfaces.INotification;
    import org.puremvc.as3.patterns.command.SimpleCommand;

    /**
     * 主应用创建完成
     * @author rhj
     * 首先会检测用户是否已登录
     */
    public class AppCreatedCommand extends SimpleCommand
    {
        public function AppCreatedCommand()
        {
            super();
        }

        override public function execute(notification:INotification):void
        {

            var m:LDiceMediator=new LDiceMediator(notification.getBody());
            facade.registerMediator(m);
            //初始化popupmanger的容器
            ModWindowManager.getInstance().init(m.popLayer);
            
            if(Config.isLogined)
            {
            	m.initModule();
            }
            else
            {
            	m.mainModule.loadModule(ModuleName.LOGIN_MODULE);
				m.chatPanel().visible=false;
            }
			
			//初始化tickmanager
			m.app.addEventListener(Event.ENTER_FRAME,function():void{
				TickManager.instance.enterFrame();
			});
			
	
			
        }
		
		
		
		

    }
}

